/**
 ----------------------
 1.当前文件用于编辑表单
 2.提供表单相关属性
 3. @param xxxFormConfig.current 指向当前选中的数据
 ----------------------
 */
import type { AxTree } from '@/api/modules/ax/tree/types';
import type { Rule } from 'ant-design-vue/es/form/interface';
import { useAxForm } from '@/utils/common/hooks';

const treeFormObj: AxTree = {
  id: 0,
  label: '',
  parentId: undefined,
  val: '',
  type: '',
  title: '',
  icon: '',
  isLeaf: '',
  style: '',
  disable: '',
  disableCheckbox: '',
  klass: '',
  extra: '',
};

// 表格校验
export const treeRules: Record<string, Rule[]> = {
  id: [{ required: false, trigger: 'change' }],
  label: [{ required: false, trigger: 'change' }],
  parentId: [{ required: false, trigger: 'change' }],
  val: [{ required: true, trigger: 'change' }],
  type: [{ required: false, trigger: 'change' }],
  title: [{ required: false, trigger: 'change' }],
  icon: [{ required: false, trigger: 'change' }],
  isLeaf: [{ required: false, trigger: 'change' }],
  style: [{ required: false, trigger: 'change' }],
  disable: [{ required: false, trigger: 'change' }],
  disableCheckbox: [{ required: false, trigger: 'change' }],
  klass: [{ required: false, trigger: 'change' }],
  extra: [{ required: false, trigger: 'change' }],
};
export const treeFormConfig = useAxForm<AxTree>(treeFormObj);
export const treeFormRef = ref();
